//
//  MusicTableViewCell.m
//  播求
//
//  Created by MS on 15-9-21.
//  Copyright (c) 2015年 gengsensen. All rights reserved.
//

#import "MusicTableViewCell.h"
#import "CellDidSelectViewController.h"
@implementation MusicTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self=[super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self creatUI];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
    }
    return  self;
}
-(void)creatUI{

    //适配人物图标
    
    self.personImageView = [[UIImageView alloc]init];
    //self.personImageView.backgroundColor = [UIColor greenColor];
    self.personImageView.layer.masksToBounds = YES;
    self.personImageView.layer.cornerRadius = self.contentView.frame.size.width/12;
    self.layer.cornerRadius = 30;
    [self.contentView addSubview:self.personImageView];
    
    [self.personImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView.mas_top).offset(5);
        make.left.equalTo(self.contentView.mas_left).offset(5);
        make.width.equalTo(@60);
        make.height.equalTo(@60);
    }];
    
    
    
    //适配人物名字
    
    self.nameLable = [[UILabel alloc]init];
    // self.nameLable.backgroundColor = [UIColor redColor];
    [self.contentView addSubview:self.nameLable];
    [self.nameLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.personImageView.mas_right).offset(5);
        make.top.equalTo(self.contentView.mas_top).offset(5);
        make.right.equalTo(self.contentView.mas_right).offset(-30);
        //make.height.equalTo(20);
        make.height.equalTo(@60);
    }];
    
    
    //适配更新时间
    
    self.dateLabel = [[UILabel alloc]init];
   // self.dateLabel.backgroundColor = [ UIColor orangeColor];
    
    [self.contentView addSubview:self.dateLabel];
    [self.dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.personImageView.mas_right).offset(5);
        make.top.equalTo(self.nameLable.mas_bottom);
        make.right.equalTo(self.nameLable.mas_right);
        make.bottom.equalTo(self.personImageView.mas_bottom);
    }];
    
    
    //适配下面评价视图
    
    self.loveButton = [[UIButton alloc]init];
    self.loveButton.layer.masksToBounds = YES;
    self.loveButton.layer.cornerRadius = 8;
    //self.loveImageView.backgroundColor = [UIColor blueColor];
    [self.contentView addSubview:self.loveButton];
    [self.loveButton setImage:[UIImage imageNamed:@"99f05305-40d6-40fa-b8ff-39276e557ac5.jpg"] forState:UIControlStateNormal];
    
    [self.loveButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView.mas_left).offset(30);
        make.bottom.equalTo(self.contentView.mas_bottom).offset(-5);
        make.width.equalTo(@60);
        make.height.equalTo(@30);
        
    }];
    
    self.loveLabel = [[UILabel alloc]init];
    //self.loveLabel.backgroundColor = [UIColor blackColor];
    [self.contentView addSubview:self.loveLabel];
    [self.loveLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.loveButton.mas_right);
        make.width.equalTo(@60);
        make.bottom.equalTo(self.loveButton.mas_bottom);
        make.height.equalTo(@60);
    }];
    
    
    self.hateButton = [[UIButton alloc]init];
    //self.hateIamgeView.backgroundColor = [UIColor redColor];
    [self.hateButton setImage:[UIImage imageNamed:@"u=1418684240,1772419212&fm=21&gp=0.jpg"] forState:UIControlStateNormal];
    
    [self.contentView addSubview:self.hateButton];
    
    [self.hateButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.loveLabel.mas_right);
        make.width.equalTo(@60);
        make.bottom.equalTo(self.loveButton.mas_bottom);
        make.height.equalTo(@60);
        
    }];
    
    
    self.hateLabel = [[UILabel alloc]init];
    // self.hateLabel.backgroundColor = [UIColor blueColor];
    [self.contentView addSubview:self.hateLabel];
    
    [self.hateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.hateButton.mas_right);
        make.width.equalTo(@60);
        make.bottom.equalTo(self.loveButton.mas_bottom);
        make.height.equalTo(@60);
        
    }];
    
    
    self.shareButton = [[UIButton alloc]init];
    self.shareButton.layer.masksToBounds = YES;
    self.shareButton.layer.cornerRadius = 8;
   // self.shareImageView.backgroundColor = [UIColor redColor];
    [self.shareButton setImage:[UIImage imageNamed:@"u=2924154818,3572729598&fm=21&gp=0.jpg"] forState:UIControlStateNormal];
   
    [self.contentView addSubview:self.shareButton];
    
    [self.shareButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.hateLabel.mas_right);
        make.width.equalTo(@60);
        make.bottom.equalTo(self.loveButton.mas_bottom);
        make.height.equalTo(@60);
        
    }];
    
    
    self.shareLabel = [[UILabel alloc]init];
   // self.shareLabel.backgroundColor = [UIColor blueColor];
    self.shareLabel.text = @"分享";
    [self.contentView addSubview:self.shareLabel];
    
    [self.shareLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.shareButton.mas_right);
        make.right.equalTo(self.contentView.mas_right);
        make.bottom.equalTo(self.loveButton.mas_bottom);
        make.height.equalTo(@60);
        
    }];
    
    
    
    
    //适配中建Texelabel
    
    self.TextLabel = [[UILabel alloc]init];
   // self.TextLabel.numberOfLines = 2;
    //self.TextLabel.backgroundColor = [UIColor yellowColor];
    [self.contentView addSubview:self.TextLabel];
    
    [self.TextLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView.mas_left).offset(20);
        make.right.equalTo(self.contentView.mas_right).offset(-20);
        make.top.equalTo(self.dateLabel.mas_bottom);
        make.height.equalTo(@20);
        
    }];
    
    self.PictureImageView = [[UIImageView alloc]init];
   
    self.PictureImageView.userInteractionEnabled = YES;
    [self.contentView addSubview:self.PictureImageView];
    

    [self.PictureImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView.mas_left).offset(20);
        make.right.equalTo(self.contentView.mas_right).offset(-20);
        make.top.equalTo(self.TextLabel.mas_bottom);
        make.bottom.equalTo(self.loveButton.mas_top).offset(-5);

        
        
    } ];
    
    
    self.ImageButton = [[UIButton alloc]init];
    self.ImageButton.backgroundColor = [UIColor clearColor];
    self.ImageButton.layer.masksToBounds = YES;
    self.ImageButton.layer.cornerRadius = 25;

    [self.PictureImageView addSubview:self.ImageButton];
    
    [self.ImageButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.PictureImageView.mas_bottom ).offset(-5);
        make.left.equalTo(self.PictureImageView.mas_left).offset(135);
        make.width.equalTo(@50);
        make.height.equalTo(@50);
        
    }];
    [self.ImageButton addTarget:self action:@selector(pressBtn:) forControlEvents:UIControlEventTouchUpInside];
    
    

    
    
    //button添加点击事件
    
    [self.loveButton addTarget:self action:@selector(DidLoveButton:) forControlEvents:UIControlEventTouchUpInside];
    [self.hateButton addTarget:self action:@selector(DidHateButton:) forControlEvents:UIControlEventTouchUpInside];
    
    [self.shareButton addTarget:self action:@selector(DidShareButton:) forControlEvents:UIControlEventTouchUpInside];
    
    
    
}
#pragma mark---cell上的点击事件
-(void)pressBtn:(UIButton *)sender{

    if ([_delegate respondsToSelector:@selector(choseTerm:)]) {
        sender.tag = self.tag;
        [_delegate choseTerm:sender];
    }
    
    
}
-(void)DidLoveButton:(UIButton*)sender{
    if ([_delegate respondsToSelector:@selector(DidSelectLoveButton:)]) {
        sender.tag = self.tag;
        [_delegate DidSelectLoveButton:sender];
    }
    
    
    
    
}
-(void)DidHateButton:(UIButton*)sender{
    
    if ([_delegate respondsToSelector:@selector(DidSelectHateButton:)]) {
        sender.tag = self.tag;
        [_delegate DidSelectHateButton:sender];
    }
    
}

-(void)DidShareButton:(UIButton*)sender{
    
    if ([_delegate respondsToSelector:@selector(DidSelectShareButton:)]) {
        sender.tag = self.tag;
        [_delegate DidSelectShareButton:sender];
    }
    
}




- (void)awakeFromNib {
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    
}

@end
